/* This sketch is to be used to control the Wendy
version of the Magurobotics fish revivifier. This 
was written in the wiring language on Arduino
IDE 1.0.5.

V0.1 - First Build

*/

#include <avr/interrupt.h>

volatile int State=0; // This defines the current state of the system. This is set via interrupts
volatile int tapcount = 0;
volatile unsigned long tap_timestamp = 0;

// pin assignments
//const int PB0 = 2;
//const int PB1 = 3;
//const int PB2 = 5;

void setup(){
  //initialize inputs
  pinMode(PB0, INPUT);
  pinMode(PB1, INPUT);
  pinMode(PB2, INPUT);
  pinMode(PA7, OUTPUT);
  pinMode(PA4, OUTPUT);
  pinMode(PA5, OUTPUT);
  pinMode(PA6, OUTPUT);
  PCMSK1 |= 0b00000010;
  GIMSK  |= 0b00100000;
  sei();
 // attachInterrupt(PB1,stateChange,RISING);
  
}


void loop(){
  switch (State){
    case 0:
      digitalWrite(PA4, LOW);
      digitalWrite(PA5, LOW);
      digitalWrite(PA6, HIGH);
      break;
    case 1:
      digitalWrite(PA4, HIGH);
      digitalWrite(PA5, LOW);
      digitalWrite(PA6, LOW);
      break;
    case 2:
      digitalWrite(PA4, HIGH);
      digitalWrite(PA5, HIGH);
      digitalWrite(PA6, LOW);
      break;
      
  }
  delay(200);
}

//void stateChange(){
ISR(PCINT1_vect){
  State=State++;
  if (State > 2){
    State=0;
  }
}
  

